<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            margin: 0px;
            padding: 0px;
            list-style: none;
        }

        body {
            display: flex;
            justify-content: center;
        }

        #box {
            width: 500px;
            height: 500px;
            border: 1px solid;
        }

        ul {
            width: 100%;
            height: 50px;
            display: flex;
        }

        ul > li {
            width:100%;
            height:100%;
            flex: 1;
            display: flex;
            justify-content: center;
            align-items: center;
            border: 1px solid #000;
        }
        .content{
            width:100%;
            height:100%;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .current {
            width:100%;
            height:100%;
            background-color:coral;
        }
    </style>
    <script src="./vue.js"></script>
    <script src="./vue-router.js"></script>
</head>
<body>
<div id="box">
    <div id="top">
        <ul>
            <router-link to="/pay" tag="li">
                <div :class="[{current : name == '待付款'}]" class="content" @click="btn_bottom('待付款')">
                    待付款
                </div>
            </router-link>
            <router-link to="/sendgoods" tag="li">
                <div :class="[{current : name == '待发货'}]"  class="content" @click="btn_bottom('待发货')">
                    待发货
                </div>
            </router-link>
            <router-link to="/receivegoods" tag="li">
                <div :class="[{current : name == '待收货'}]"  class="content" @click="btn_bottom('待收货')">
                    待收货
                </div>
            </router-link>
        </ul>
    </div>
    <div id="content">
<router-view/>
    </div>
</div>

<script>
    // 组件的模板对象
    let Pay = {
        template: `<div style="width:100%;height:450px;display:flex;justify-content:center;align-items:center;font-size: 50px"">待付款商品信息</div>`
    }
    let Sendgoods = {
        template: `<div style="width:100%;height:450px;display:flex;justify-content:center;align-items:center;font-size: 50px"">待发货商品信息</div>`
    }
    let Receivegoods = {
        template: `<div style="width:100%;height:450px;display:flex;justify-content:center;align-items:center;font-size: 50px"" >待收货商品信息</div>`
    }

    let router = new VueRouter({
        routes: [
            {path: '/', redirect: '/pay'}, // 路由重定向
            {path: '/pay', component: Pay},
            {path: '/sendgoods', component: Sendgoods},
            {path: '/receivegoods', component: Receivegoods},
        ]
    })
    var vm = new Vue({
        el: '#box',
        router,  // 挂载路由
        data: {
            name: '待付款'
        },
        methods: {
            btn_bottom(e) {
                this.name = e
            }
        }
    })
</script>


</body>
</html>
